<?php

namespace app\admin\validate;

use think\Validate;

class DormitoryBuilding extends Validate
{

    /**
     * 验证规则
     */
    protected $rule = [
        'garden_number'    => 'require',
        'number'           => 'require|unique:DormitoryBuilding,number^garden_number',
        'name'             => 'require',
        'floor_count'      => 'require',
        'floor_dorm_count' => 'require',
        'dorm_price'       => 'require',
        'dorm_type'        => 'require',
        'dorm_category'    => 'require',
        'dorm_bed_count'   => 'require',
    ];

    /**
     * 提示消息
     */
    protected $message = [
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['number', 'name', 'garden_number', 'floor_count', 'floor_dorm_count', 'dorm_price', 'dorm_type', 'dorm_category', 'dorm_bed_count'],
        'edit' => ['name', 'floor_count', 'floor_dorm_count', 'dorm_price', 'dorm_type', 'dorm_category', 'dorm_bed_count'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'number' => __('Number'),
            'name' => __('Name'),
        ];
        parent::__construct($rules, $message, $field);
    }

}
